<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>放生物种</title>

    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />


    <script type="text/javascript" src="{MODULE_URL}public/fo/js/flexible.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/pageLoading.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/jquery.js"></script>
    <script type="text/javascript" src="{MODULE_URL}public/fo/js/layer.js"></script>
    <link type="text/css" rel="stylesheet" href="{MODULE_URL}public/fo/css/release.css">

</head>

<body>
<!-- 一天放生一次后弹窗begin -->
<div class="indextip" id="indextip" style="display: none;">
    <div class="close_tan"></div>
    <div class="cont">
        感恩您的慈悲放生！您今天的放生次数已用完，望您明日继续来放生，解救众生性命，功德无量。
    </div>
</div>
<!-- 一天放生一次后弹窗end -->

<div class="loadDiv">
    <!--<div class="loadContent">每个月，我们将举行线下放生活动，您在这里放生一次，不仅是拯救线上的众生，更是在拯救线下真实的生命，放生得越多，就解救得更多。希望您每天坚持放生，苦难众生将因此得到解救。</div>-->
    <div class="loadContent"></div>
    <a href="javaScript:;" class="myBtn" id="myBtn">选择放生种类</a>
</div>

<div class="sortBg">
    <div class="close"></div>
    <div class="sort">
        <ul>
            <li><img src="{MODULE_URL}public/fo/images/yu.png" alt="泥鳅" data-cid="47"  data-qj="{MODULE_URL}public/fo/images/yu2.png" data-qlm="{MODULE_URL}public/fo/images/yu3.png" data-qrm="" data-price="0.00"/><span></span><b>泥鳅 免费</b></li>
            <li><img src="{MODULE_URL}public/fo/images/gui.png" alt="乌龟" data-cid="48"  data-qj="{MODULE_URL}public/fo/images/gui2.png" data-qlm="{MODULE_URL}public/fo/images/gui2.png" data-qrm="" data-price="28.88"/><span></span><b>乌龟  28.88元</b></li>
            <li><img src="{MODULE_URL}public/fo/images/ly.png" alt="草鱼" data-cid="49"  data-qj="{MODULE_URL}public/fo/images/ly2.png" data-qlm="{MODULE_URL}public/fo/images/ly3.png" data-qrm="" data-price="2.88"/><span></span><b>草鱼  2.88元</b></li>
            <li><img src="{MODULE_URL}public/fo/images/sy.png" alt="鲫鱼" data-cid="50"  data-qj="{MODULE_URL}public/fo/images/sy2.png" data-qlm="{MODULE_URL}public/fo/images/sy3.png" data-qrm="" data-price="1.88"/><span></span><b>鲫鱼  1.88元</b></li>
            <li><img src="{MODULE_URL}public/fo/images/bl.png" alt="白鲢鱼" data-cid="51"  data-qj="{MODULE_URL}public/fo/images/bl2.png" data-qlm="{MODULE_URL}public/fo/images/bl3.png" data-qrm="" data-price="0.88"/><span></span><b>白鲢鱼  0.88元</b></li>
            <li><img src="{MODULE_URL}public/fo/images/jy.png" alt="甲鱼" data-cid="52"  data-qj="{MODULE_URL}public/fo/images/jy2.png" data-qlm="{MODULE_URL}public/fo/images/jy3.png" data-qrm="" data-price="18.88"/><span></span><b>甲鱼  18.88元</b></li>
        </ul>
    </div>
</div>
<div class="numberBg">
    <a href="javaScript:;" class="return"></a>
    <div class="number">
        <div class="numberList">
            <img src="{MODULE_URL}public/fo/images/hong-r.png" alt="数量" data-qj="" data-qlm="" data-qrm="" data-price=""/>
            <span></span>
            <b>红鲤鱼</b>
        </div>
        <div class="numberPage">
            <span class="fangSpan">放生数量</span>
            <div class="Numsore">
                <div class="allNum"><i class="jian"></i><span class="inpNum">1</span><i class="add"></i></div>
            </div>
        </div>
        <a href="javaScript:;" class="btnOK" id="btnOK">确定</a>
        <input type="hidden" name="cid" id="cid" value="" />
    </div>
</div>

<div class="beginRelase">
    <div class="relaseAll">
        <div class="Reclose_A"><a href="javaScript:;" class="Relase_close" >X</a></div>
        <div class="Relase_cont">放生前，请先念三遍三皈依：皈依佛，不落地狱；皈依法，不落饿鬼；皈依僧，不落畜生。然后再念三遍：南无阿弥陀佛。愿你们彻底脱离苦海，修成佛道，往生极乐世界。</div>
    </div>
    <a href="javaScript:;" class="subRelase" id="subRelase">开始放生</a>
</div>

<div class="releaseBack">
    <div class="BackAll">
        <div class="Back_A"><a href="javaScript:;" class="Back_close" >X</a></div>
        <div class="Back_cont">&nbsp;&nbsp;<span id="fs_tip">您已放生1天，还需连续放生6天即可上功德榜！</span>放生就是救命，放生就是延寿，将无尽功德回向给亲友，消灾免难。</div>
    </div>
    <a href="javaScript:;" class="subBack" id="subBack">回向功德</a>
</div>

<div class="releaseBack_OK">
    <div class="Back_OKAll">
        <a href="javaScript:;" class="Back_OK_close" >X</a>
        <div class="Back_OK_cont">
            <div class="backTitle">
                <span class="spanTiltle">善信佛子：</span>
           <span class="TiltleName">
             <input type="text" value="" class="backInp1"/>
           </span>
                <div class="clear"></div>
                <div class="backContent">
             <span class="spanContent">
             愿以此功德，普及于一切。
             我等与众生，皆共成佛道。
             </span>
                </div>
            </div>
            <div class="backWho">
                <span class="spanWho">特别回向给：</span>
           <span class="whoName">
             <input type="text" value="" id="toname" class="backInp"/>
           </span>
            </div>
            <div class="backWish">
                <span class="spanWish">愿他（她）：</span>
           <span class="wishCont">
             <input type="text" value="" id="content" class="backInp"/>
           </span>
            </div>
        </div>
    </div>
    <input type="hidden" id="pid" value="" />
    <a href="javaScript:;" class="subBack_OK" id="subBack_OK">确认回向</a>
</div>

<div class="releaseShare" style="display:none;">
    <div class="ShareAll">
        <a href="javaScript:;" class="Share_close" >X</a>
        <div class="Share_cont">
            <div class="backShare">
                <span class="spanShare">善信佛子：</span>
                <span class="shareNameInp"></span>
                <div class="clear"></div>
                <div class="shareContent">
             <span class="spanshareCont">
             愿以此功德，普及于一切。<br/>我等与众生，皆共成佛道。
             </span>
                </div>
            </div>
            <div class="shareWho">
                <span class="sharespanWho">特别回向给：</span>
                <span class="sharewhoInp"></span>
            </div>
            <div class="shareWish">
                <span class="shareWishHe">愿他（她）：</span>
                <span class="shareWishInp"></span>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <a href="javaScript:;" class="subShare" id="subShare">分享</a>
</div>

<div class="fish">
    <div class="fishLeft fish1"></div>
    <div class="fishRight fish2"></div>
    <div class="fishLm fish3"></div>
    <div class="fishRm fish4"></div>
</div>
<div class="bubble"><p></p></div>

<div id="mask"></div>
<div id="mask2"></div>
<div id="mask3"></div>
<div id="share"></div>


{template 'fangshengfoot'}


<script src="{MODULE_URL}public/fo/js/zepto.min.js"></script>
<script src="{MODULE_URL}public/fo/js/fun.js"></script>
<script type="text/javascript">

    $(window).on("load",function(e){
        e.preventDefault();
        $(".loadDiv").show();
        $("#mask").show();

    })

    $('.close_tan').on('tap', function(){
        $(this).parent().css('display', 'none');
    });

    $("#myBtn").on("click",function(e){
        var isFangsheng = '0';  	//今天是否放生
        if(parseInt(isFangsheng)){
            $(".loadDiv").hide();
            $("#mask").hide();
            $('#indextip').css('display', 'block');
        }else{
            e.preventDefault();
            $(".sortBg").show();
            $(".fish").css({'opacity':'1','display':'none'});
            $(".bubble").css({'opacity':'1','display':'none'});
            $(".loadDiv").hide();
        }
    });
    $(".sort ul li").on("click",function(){
        var srcId = $(this).find('img').attr("data-cid");

        var srcPath = $(this).find('img').attr("src");
        var srcLeft = $(this).find('img').attr("data-qj");
        var srclm = $(this).find('img').attr("data-qlm");
        var srcrm = $(this).find('img').attr("data-qrm");
        var price = $(this).find('img').attr("data-price");
        $(".numberList>img").attr("src",srcPath).attr("data-qj",srcLeft).attr("data-qlm",srclm).attr("data-qrm",srcrm).attr("data-price",price);
        var text = $(this).find('b').text();
        $(".numberList>b").text(text);
        $(".numberBg").show();
        $(".sortBg").hide();

        $('#cid').val(srcId);
    });
    $(".return").click(function(){
        $(".sortBg").show();
        $(".numberBg").hide();

    });
    $("i.jian").click(function(){ //减少数量
        var Num = $(".inpNum").text();
        if(Num>1){
            Num--;
            $(".inpNum").text(Num);
        }
    })
    $("i.add").click(function(){  //增加数量
        var Num = $(".inpNum").text();
        if(Num<10){
            Num++;
            $(".inpNum").text(Num);
        }
    })
    $("#btnOK").on("click",function(){ //确定条数后确认
        $(".sortBg").hide();
        $("#mask2").show();
        $(".beginRelase").show();
        var dataLeft = $(".numberList>img").attr("src");
        var dataRight = $(".numberList>img").attr("data-qj");
        var dataLm = $(".numberList>img").attr("data-qlm");
        var dataRm = $(".numberList>img").attr("data-qrm");
        //alert(dataLeft+dataRight);
        $(".fishLeft").css('background-image','url('+dataLeft+')');
        $(".fishRight").css('background-image','url('+dataRight+')');
        $(".fishLm").css('background-image','url('+dataLm+')');
        $(".fishRm").css('background-image','url('+dataRm+')');

    })
    $(".close").click(function(){ //关闭种类弹窗
        $(".sortBg").hide();
        $("#mask").hide();
    });

    $("#subRelase").one("click",function(){   //确认放生
        var cid = $('#cid').val();
        var num = parseInt($(".inpNum").text());
        var price=$(".numberList>img").attr("data-price");
        var totalprice=num*price;

        if(totalprice>0){
            $.ajax({
                url : "./index.php?i=17&c=entry&do=release&m=we7_fangsheng",
                type : 'POST',
                dataType : 'json',
                data : {
                    'op':'pay_info',
                    'totalprice' : totalprice,
                },
                success : function(rdata){
                    layer.closeAll('dialog');
                    if(rdata['message']['status'] == 1){
                        wx.chooseWXPay({
                            timestamp: rdata['message']['timeStamp'],
                            nonceStr: rdata['message']['nonceStr'],
                            package: rdata['message']['package'],
                            signType: 'MD5', // 注意：新版支付接口使用 MD5 加密
                            paySign: rdata['message']['paySign'],

                            success: function (res) {

                                $.ajax({
                                    url:"./index.php?i=17&c=entry&do=release&m=we7_fangsheng",
                                    type:"POST",
                                    dataType : 'json',
                                    data:{
                                        'op':'update',
                                        'id' : 2,
                                        'totalprice' : totalprice,
                                        'cid' : cid,
                                        'num' : num,
                                    },
                                    success: function(rdata){
                                        if(rdata['message']['status']==1){
                                            $('#pid').val(rdata['message']['uplogid']);
                                            $('.backInp1').val(rdata['message']['nickname']);

                                            if(rdata['message']['continue'] < parseInt("7")){
                                                $('#fs_tip').html("您已放生"+rdata['message']['continue']+"天，还需连续放生"+(parseInt("7")-parseInt(rdata['message']['continue']))+"天即可上功德榜！");
                                            }else{
                                                $('#fs_tip').html("您已连续放生"+rdata['message']['continue']+"天,已经登上功德榜！");
                                            }
                                            $(".fish").show();
                                            $(".bubble").show();
                                            $("#mask2").hide();
                                            $(".beginRelase").hide();
                                            $(".numberBg").hide();
                                            $("#mask").hide();
                                            var NumOK = $(".inpNum").text();
                                            $(".fish").css("animation-play-state","running");
                                            $(".fish").css("-webkit-animation-play-state","running");
                                            //$(".bubble>p").text("您已放生"+NumOK+rs.unit);
                                            $(".bubble>p").text("您已放生"+NumOK+rdata['message']['name']);
                                            $(".fishLeft").css("animation-play-state","running");
                                            $(".fishLeft").css("-webkit-animation-play-state","running");
                                            $(".fishLm").css("animation-play-state","running");
                                            $(".fishLm").css("-webkit-animation-play-state","running");
                                            $(".fishRight").css("animation-play-state","running");
                                            $(".fishRight").css("-webkit-animation-play-state","running");
                                            $(".fishRm").css("animation-play-state","running");
                                            $(".fishRm").css("-webkit-animation-play-state","running");
                                            $(".bubble").css("animation-play-state","running");
                                            $(".bubble").css("-webkit-animation-play-state","running");

                                            setTimeout(blackTan,5000);

                                        }
                                        else if(rdata['message']['status']==2){
                                            layer.msg(rdata['message']['msg']);
                                        }
                                    },
                                    error: function(data){
                                        layer.msg("支付成功后跳转，操作失败！");
                                    }
                                });
                            },
                            cancel: function () {
                                layer.msg("取消支付");
                            }
                        });
                    }else if(rdata['message']['status'] == 2){
                        layer.msg(rdata['message']['msg']);
                    }
                },
                error : function(){
                    layer.msg('支付操作失败');
                }
            });

            return

        }else { $.ajax({
            url:"./index.php?i=17&c=entry&do=release&m=we7_fangsheng",
            type:"POST",
            dataType : 'json',
            data:{
                'op':'update',
                'cid' : cid,
                'num' : num,
            },
            success: function(rdata){
                if(rdata['message']['status']==1){
                    $('#pid').val(rdata['message']['uplogid']);
                    $('.backInp1').val(rdata['message']['nickname']);

                    if(rdata['message']['continue'] < parseInt("7")){
                        $('#fs_tip').html("您已放生"+rdata['message']['continue']+"天，还需连续放生"+(parseInt("7")-parseInt(rdata['message']['continue']))+"天即可上功德榜！");
                    }else{
                        $('#fs_tip').html("您已连续放生"+rdata['message']['continue']+"天,已经登上功德榜！");
                    }
                    $(".fish").show();
                    $(".bubble").show();
                    $("#mask2").hide();
                    $(".beginRelase").hide();
                    $(".numberBg").hide();
                    $("#mask").hide();
                    var NumOK = $(".inpNum").text();
                    $(".fish").css("animation-play-state","running");
                    $(".fish").css("-webkit-animation-play-state","running");
                    //$(".bubble>p").text("您已放生"+NumOK+rs.unit);
                    $(".bubble>p").text("您已放生"+NumOK+rdata['message']['name']);
                    $(".fishLeft").css("animation-play-state","running");
                    $(".fishLeft").css("-webkit-animation-play-state","running");
                    $(".fishLm").css("animation-play-state","running");
                    $(".fishLm").css("-webkit-animation-play-state","running");
                    $(".fishRight").css("animation-play-state","running");
                    $(".fishRight").css("-webkit-animation-play-state","running");
                    $(".fishRm").css("animation-play-state","running");
                    $(".fishRm").css("-webkit-animation-play-state","running");
                    $(".bubble").css("animation-play-state","running");
                    $(".bubble").css("-webkit-animation-play-state","running");

                    setTimeout(blackTan,5000);

                }else if(rdata['message']['status']==2){
                    layer.msg(rdata['message']['msg']);
                }
            },
            error: function(data){
            }
        })
        }

        //$.post("/index.php?g=Wap&m=Fangsheng&a=toFangsheng",{cid:cid,num:num},function(rs){
        //if(rs.code==200){
        //$('#pid').val(rs.lastID);
        /*if(rs.coutinue < parseInt("7")){
         $('#fs_tip').html("您已放生"+rs.coutinue+"天，还需连续放生"+(parseInt("7")-parseInt(rs.coutinue))+"天即可上功德榜！");
         }else{
         $('#fs_tip').html("您已连续放生"+rs.coutinue+"天,已经登上功德榜！");
         }*/
        //}
        //},'json');
    })

    function blackTan(){
        $(".releaseBack").show();
        $("#mask2").show();
        $(".fish").css('opacity','0');
        $(".bubble").css('opacity','0');

    }
    $("a.Relase_close").click(function(){  //默念弹窗关闭
        $("#mask2").hide();
        $(".beginRelase").hide();


    })
    $(".Back_close").on("click",function(){  //回向功能关闭
        $(".releaseBack").hide();
        $("#mask2").hide();
        $(".fish").css("animation-play-state","paused");
        $(".fish").css("-webkit-animation-play-state","paused");
        $(".fishLeft").css("animation-play-state","paused");
        $(".fishLeft").css("-webkit-animation-play-state","paused");
        $(".fishLm").css("animation-play-state","paused");
        $(".fishLm").css("-webkit-animation-play-state","paused");
        $(".fishRm").css("animation-play-state","paused");
        $(".fishRm").css("-webkit-animation-play-state","paused");
        $(".fishRight").css("animation-play-state","paused");
        $(".fishRight").css("-webkit-animation-play-state","paused");
        $(".bubble").css("animation-play-state","paused");
        $(".bubble").css("-webkit-animation-play-state","paused");
        $(".fish").hide();
        $(".bubble").hide();
    })
    $(".Back_OK_close").click(function(){  //确认回向关闭
        $("#mask2").hide();
        $(".releaseBack_OK").hide();
    })
    $(".Share_close").click(function(){
        $("#mask2").hide();
        $(".releaseShare").hide();
    })
    $("#subBack").click(function(){
        $(".releaseBack").hide();
        $(".releaseBack_OK").show();
    })
    $(".subBack_OK").on("click",function(){ //确认回向按钮

        var pid  = $('#pid').val();
        var nickname = $('.backInp1').val();
        var toname  = $.trim($('#toname').val());
        var content = $.trim($('#content').val());
        $.ajax({
            url:"./index.php?i=17&c=entry&do=release&m=we7_fangsheng",
            type:"POST",
            dataType : 'json',
            data:{
                'op':'back',
                'toname' : toname,
                'content' : content,
                'nickname' : nickname,
                'pid' : pid,
            },
            success: function(rdata){
                if(rdata['message']['status']==1){
                    $(".subBack_OK").hide();
                    $(".releaseShare").show();
                    var title = $(".TiltleName>input").val();
                    var name = $(".whoName>input").val();
                    var content = $(".wishCont>input").val();
                    $(".shareNameInp").text(rdata['message']['nickname']);
                    $(".sharewhoInp").text(rdata['message']['name']);
                    $(".shareWishInp").text(rdata['message']['content']);

                }else if(rdata['message']['status']==2){
                    layer.msg(rdata['message']['msg']);
                }
            },
            error: function(data){
            }
        });
        //$.post("/index.php?g=Wap&m=Fangsheng&a=merit_back",{toname:toname,pid:pid,content:content},function(rs){
        //if(rs.code==200){
        /*
         $(".releaseBack_OK").hide();
         $(".releaseShare").show();
         var title = $(".TiltleName>input").val();
         var name = $(".whoName>input").val();
         var content = $(".wishCont>input").val();
         $(".shareNameInp").text(title);
         $(".sharewhoInp").text(name);
         $(".shareWishInp").text(content);
         */
        //location.href = 'index.php?g=Wap&m=Fangsheng&a=merit_back&token=naiafu1465970473&pid='+rs.pid;

        //test

        //}
        //},'json');

    })
    $("#subShare").click(function(){
        $(".releaseShare").hide();
        $("#share").show();
        $("#mask3").show();
        $("#mask2").hide();

    })
    $("#share").click(function(){
        $("#share").hide();
        $("#mask2").hide();
        $("#mask3").hide();
    })
</script>


</body>

</html>
